package com.hangxiang.approval.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hangxiang.approval.common.ActioncolumnInsertCommon;
import com.hangxiang.approval.common.ActioncolumnUpdateCommon;
import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.dao.ActioncolumnDao;
import com.hangxiang.approval.entity.Actioncolumn;
import com.hangxiang.approval.service.ActioncolumnService;
import com.hangxiang.approval.vo.ActioncolumnVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


/**
 * (Actioncolumn)表服务实现类
 *
 * @author makejava
 * @since 2020-11-25 11:28:23
 */
@Service("actioncolumnService")
public class ActioncolumnServiceImpl extends ServiceImpl<ActioncolumnDao, Actioncolumn> implements ActioncolumnService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private ActioncolumnDao actioncolumnDao;

    /**
     * 通过ID查询单条数据
     *
     * @param common 主键
     * @return 实例对象
     */
    @Override
    public ActioncolumnVo queryById(IntegerCommon common) {
        ActioncolumnVo vo = new ActioncolumnVo();
        Actioncolumn actioncolumn = actioncolumnDao.selectById(common.getValue());
        BeanUtils.copyProperties(actioncolumn, vo);
        return vo;
    }


    /**
     * 新增数据
     *
     * @param actioncolumnInsertCommon 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public Integer insertActioncolumn(ActioncolumnInsertCommon actioncolumnInsertCommon) {
        Actioncolumn actioncolumn = new Actioncolumn();
        BeanUtils.copyProperties(actioncolumnInsertCommon, actioncolumn);
        actioncolumnDao.insert(actioncolumn);
        return actioncolumn.getActioncolumnId();
    }

    /**
     * 修改数据
     *
     * @param actioncolumnUpdateCommon 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public Integer updateActioncolumn(ActioncolumnUpdateCommon actioncolumnUpdateCommon) {
        Actioncolumn actioncolumn = new Actioncolumn();
        BeanUtils.copyProperties(actioncolumnUpdateCommon, actioncolumn);
        actioncolumnDao.updateById(actioncolumn);
        return actioncolumn.getActioncolumnId();
    }
}